<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let input =`6 2
        1 2
        2 4
        3 1
        4 2
        5 3
        6 4`

        let list=input.split('\n').map(v=>v.trim().split(' ').map(j=>parseInt(j.trim())))
        let [n,m]=list.shift()
        let cai_time_list=new Array(n).fill(0)

        for(let i=0;i<n;i++){
            cai_time_list[i]=list[i][0]+list[i][1]
        }
        cai_time_list.sort((a,b)=>a-b)
        
        let last=3
        let count=1
        for(let i=1;i<cai_time_list.length;i++){
            if(cai_time_list[i]-last>=m){
                last=cai_time_list[i]
                count++
                
            }
        }

        console.log(cai_time_list,count);
        
        

    </script>
</body>
</html>